#pragma once

#include <Windows.h>
#include <vector>
#include <gl\GL.h>
#include <gl\GLU.h>
using std::vector;

struct Vertex3D		{ float x, y, z; };
struct TexCoord2D	{ float u, v; };
struct Triangle
{
	int * vIndex;
	int * tIndex;
	int * nIndex;
	GLuint * textureId;

	Triangle()
	{
		textureId = NULL;
		vIndex = tIndex = nIndex = NULL;
	}
	bool hasMaterial()
	{
		return (textureId != NULL);
	}
};

class Mesh
{
private:
	vector<Vertex3D>		vertices;
	vector<TexCoord2D>		texCoords;
	vector<Triangle>		faces;
	vector<GLuint>			materials;

public:
	typedef vector<Triangle>::iterator FaceIterator;

	Mesh(void);
	~Mesh(void);

	void					addVertex(Vertex3D& p);
	void					addTexCoord(TexCoord2D& t);
	void					addFace(Triangle& f);
	void					addMaterial(GLuint m);
	void					debug();
	FaceIterator			getFaceStartIter();
	FaceIterator			getFaceEndIter();
	Vertex3D&				getVertexAt(int pos);
	TexCoord2D&				getTexCoordAt(int pos);
};
